package com.htl.线程.sleep_wait;

import java.util.concurrent.TimeUnit;

/**
 *  三、如果 synchronized 静态方法和 synchronized 非静态方法同时存在，
 *      静态方法锁类，实例方法锁对象。
 */

public class Synchronized03 {
    public static void main(String[] args) {
        Date3 date1 = new Date3();
        Date3 date2 = new Date3();

        new Thread(()->{
            date1.func1();
        }).start();

        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        new Thread(()->{
            date2.func2();
        }).start();
    }
}


class Date3{
    public synchronized static void func1(){
        try {
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("1...");
    }
    public synchronized void func2(){
        System.out.println("2...");
    }
}
